package com.platform.service.impl;


import com.platform.dao.HomePageDao;
import com.platform.service.GoodsService;
import com.platform.service.HomePageService;
import com.platform.service.OrderService;
import com.platform.service.UserService;
import com.platform.utils.DateUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service("homePageService")
public class HomePageServiceImpl implements HomePageService {
    @Autowired
    private HomePageDao homePageDao;


    public Object dataStatistics(Map<String,Object> map){
        String time = map.get("time").toString();
        //商品总数
        Map<String,Object> goodsMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            goodsMap.put("addTime",time);
        }
        int goodsCount=homePageDao.queryGoodsTotal(goodsMap);

        //用户总数
        Map<String,Object> userMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            userMap.put("registerTime",time);
        }
        int userCount=homePageDao.queryUserTotal(userMap);

        //今日新增用户数
        Map<String,Object> newAddUserMap=new HashMap<>();
        newAddUserMap.put("registerTime", DateUtils.format(new Date(),"yyyy-MM-dd"));
        int newAddUserCount=homePageDao.queryUserTotal(newAddUserMap);

        //购物车记录
        Map<String,Object> cartMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            cartMap.put("addTime",time);
        }
        int cartCount=homePageDao.queryCartTotal(cartMap);

        //订单总数据
        Map<String,Object> orderMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            orderMap.put("addTime",time);
        }
        int orderCount=homePageDao.queryOrderTotal(orderMap);

        //今日新增代付款
        Map<String,Object> waitPayMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            waitPayMap.put("addTime",time);
        }
        waitPayMap.put("orderStatus",0);
        int waitPayCount=homePageDao.queryOrderTotal(waitPayMap);

        //新增已付款
        Map<String,Object> paidMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            paidMap.put("addTime",time);
        }
        paidMap.put("payStatus",2);
        int paidCount=homePageDao.queryOrderTotal(paidMap);

        //成交额
        Map<String,Object> turnoverMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            paidMap.put("addTime",time);
        }
        paidMap.put("payStatus",2);
        BigDecimal turnoverCount=homePageDao.queryTurnover(turnoverMap);

        //今日新增成交额
        Map<String,Object> newAddTurnoverMap=new HashMap<>();
        if (StringUtils.isNotBlank(time)){
            paidMap.put("addTime",time);
        }
        paidMap.put("payStatus",2);
//        BigDecimal turnoverCount=homePageDao.queryTurnover(turnoverMap);
        return null;
    }
}
